package cn.com.dcsgo.library.client.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 图书借阅状态
 *
 * @author Dcsgo
 * @since 2024/9/3 17:04
 */
@Getter
@AllArgsConstructor
public enum BookStatus {
    IN_PAVILION(0, "在馆"),
    BORROWING(1, "借阅中"),
    OVERDUE(2, "逾期"),
    RETURNED(3, "已归还");
    @EnumValue
    private final Integer value;
    @JsonValue
    private final String desc;

    public static BookStatus ofValue(Integer value) {
        return switch (value) {
            case 0 -> IN_PAVILION;
            case 1 -> BORROWING;
            case 2 -> OVERDUE;
            case 3 -> RETURNED;
            default -> throw new IllegalArgumentException("don't exists value of " + value);
        };
    }
}
